<?php
/*
	[BuyPg] (C) 2010-2011 Buypg
	$Id: BizModel.class.php 2011-5-10 14:18:13 wufujun $
 */
if (!defined('THINK_PATH')) {
	exit('Access Denied');
}

class CommproductModel extends Model {
	
	//自动验证
	protected $_validate = array(
		array('product_name','require','请填写商品名称',1),
		array('product_img' ,'require','请填写图片网址',1), 
		array('product_link','require','请填写商品链接',1),
		array('product_price','require','请填写商品价格',1),
	);
	//自动填充
	protected $_auto = array(
		array('site_id','getsiteid',1,'callback'),
		array('zhuanti_id','getzhuantiid',1,'callback'),
		array('biz_id','getbizid',1,'callback'),
		array('product_link','urlencode',3,'function'),
		array('product_date','getTimeToStr',3,'function'),
		array('product_dt','getNowTime',1,'function'),
		array('editor_id','0',1),
		array('click_count','0',1),
	);
	//get zhuanti_id
	public function getzhuantiid()
	{
		global $_SGLOBAL;
		$DbSite = M("NbSite");
		$arrSite = $DbSite->where("site_id =" . $_SGLOBAL['G_siteid'])->find();
		$zhuanti_id = $arrSite['zhuanti_id'];
		return $zhuanti_id;
		//return "0";
	}
	//get site_id
	public function getsiteid()
	{
		global $_SGLOBAL;
		return $_SGLOBAL['G_siteid'];
	}
	//get biz_id
	public function getbizid()
	{
		global $_SGLOBAL;
		return $_SGLOBAL['G_uid'];
	}

}

?>